import { setGlobal } from '@swda/utils'


let SWDAWindowManager = {};
SWDAWindowManager.commandItemMenuButtonImage = 'MenuButton_MainItem'


//-----------------------------------------------------------------------------
// SWDA_Window_ItemMenuCommand
//
// The window for selecting a command on the menu screen.
class SWDA_Window_ItemMenuCommand extends SWDA_Window_Command_4Arrows {
    constructor() {
        super(...arguments)
        this.initialize(...arguments);
    }

    initialize(x, y) {
        super.initialize(x, y)
        this.selectLast();
        this.createButtons(SWDAWindowManager.commandItemMenuButtonImage);
    }

    windowWidth() {
        return 240
    }

    numVisibleRows() {
        return this.maxItems()
    }

    initCommandPosition() {
        this._lastCommandSymbol = null;
    }



    makeCommandList() {
        this.addMainCommands();
    }

    addMainCommands() {
        this.addCommand('', '', false);
        this.addCommand(TextManager.item, 'item', true);
        this.addCommand('', '', false);
        this.addCommand(TextManager.equip, 'equip', true);
    }


    processOk() {
        SWDA_Window_ItemMenuCommand._lastCommandSymbol = this.currentSymbol();
        Window_Command.prototype.processOk.call(this);
    }

    selectLast() {
        this.selectSymbol(SWDA_Window_ItemMenuCommand._lastCommandSymbol);
    };

}
SWDA_Window_ItemMenuCommand._lastCommandSymbol = null;



setGlobal('SWDA_Window_ItemMenuCommand', SWDA_Window_ItemMenuCommand)